package com.menglei.dailytasks.m0716;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBHelper extends SQLiteOpenHelper {

    //带全部参数的构造函数，此构造函数必不可少,name为数据库名称
    public DBHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    //创建表
    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table user(name varchar(20))";
        db.execSQL(sql);
    }
    //这里应当实现数据库升级等操作，由于是简 单demo，所以就不写了
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
